//
//  EXT+UIImageView.swift
//  WB25
//
//  Created by HM on 2017/6/29.
//  Copyright © 2017年 itheima. All rights reserved.
//

import UIKit
import SDWebImage

extension UIImageView {
    // 快速实例化一个ImageView
    convenience init(named: String){
        self.init(image: UIImage(named: named))
    }
    
    // 对sd进行封装
    func hm_setImage(withUrlString: String?, placeholderImgName:String? = nil){

        if placeholderImgName == nil {
            self.sd_setImage(with: URL(string: withUrlString ?? ""), placeholderImage: self.image)
        }else{
            self.sd_setImage(with: URL(string: withUrlString ?? ""), placeholderImage: UIImage(named: placeholderImgName ?? ""))
        }
        
        
    }
}
